import { createContext, useState,useContext } from "react";

const AuthContext = createContext();  
export const useAuth = () =>{
    return useContext(AuthContext);  
}
export const AuthProvider = (props) =>{
    const [isLogin,setIsLogin] = useState(localStorage.getItem('isLogin') || false);
    //先从本地获取，获取到isLogin值就用，没有则赋值为false

    return(
        <AuthContext.Provider value={{isLogin,setIsLogin}}>
            {props.children}      
        </AuthContext.Provider>
    )
}
